{
  (function(){
    var arr=[];
    for(let i=0;i<3;i++){
      var cale=function(){
        return i*i
      }
      arr.push(cale);
    };
    for(let i=0;i<arr.length;i++){
      console.log(arr[i]());//0,1,4
    }
  })()
}

{
    (function(){
      let arr=[];
      for(let i=0;i<3;i++){
        var param=i;
        var calc=function(){
          return param*param
        }
        arr.push(calc)
      }
      for(let i=0;i<arr.length;i++){
        console.log(arr[i]());//4,4,4
      }
    })()
}

{
  async function async1(){
    console.log('async1 start');
    await async2();
    console.log('async1 end');
  }
  async function async2(){
    console.log('async2');
  }
  console.log('script start');
  setTimeout(function () {
    console.log('setTimeout');
  }, 0);
  async1();
  new Promise(function(resolve){
    console.log('promise1');
    resolve();
  }).then(function(){
    console.log('promise 2');
  })
  console.log('script end');

/**
 * script start
 * async1 start
 * async2
 * promise1
 * script end
 * promise 2
 * async1 end
 * setTimeout
 */

}
